# This is a basic playbook

- name: dole out the basic configuration
  hosts: nfs_servers
  user: root
  gather_facts: True

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  pre_tasks:
  - import_tasks: "{{ tasks_path }}/yumrepos.yml"

  roles:
  - base
  - rkhunter
  - hosts
  - ipa/client
  - nagios_client
  - collectd/base
  - sudo
  - openvpn/client

  tasks:
  - import_tasks: "{{ tasks_path }}/motd.yml"

  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"

## This should be in a different playbook.
- name: Deal with drive items on storinator01
  hosts: storinator01.rdu-cc.fedoraproject.org
  user: root
  gather_facts: True
  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"

  tasks:
    - name: Create top level directory
      file: path=/srv/nfs state=directory owner=root group=root
      tags:
        - drives
        - copr

    - name: create copr-dist-git storage
      lvol: vg=VG_nfs lv=copr-dist-git size=10t shrink=no
      tags:
        - drives
        - copr

    - name: Create FS for copr-dist-git
      filesystem: fstype=xfs dev=/dev/VG_nfs/copr-dist-git
      tags:
        - drives
        - copr

    - name: Create copr-dist-git tree directory
      file: path=/srv/nfs/copr-dist-git state=directory owner=root group=root
      tags:
        - drives
        - copr

    - name: Mount copr-dist-git tree directory
      mount: name=/srv/nfs/copr-dist-git src=/dev/mapper/VG_nfs-copr--dist--git fstype=xfs state=mounted
      tags:
        - drives
        - copr

    - name: create dev copr-dist-git-dev storage
      lvol: vg=VG_nfs lv=copr-dist-git-dev size=1t shrink=no
      tags:
        - drives
        - copr

    - name: Create FS for dev copr-dist-git-dev
      filesystem: fstype=xfs dev=/dev/VG_nfs/copr-dist-git-dev
      tags:
        - drives
        - copr

    - name: Create dev copr-dist-git tree directory
      file: path=/srv/nfs/copr-dist-git-dev state=directory owner=root group=root
      tags:
        - drives
        - copr

    - name: Mount dev copr-dist-git tree directory
      mount: name=/srv/nfs/copr-dist-git-dev src=/dev/mapper/VG_nfs-copr--dist--git--dev fstype=xfs state=mounted
      tags:
        - drives
        - copr

    - name: create copr-be storage
      lvol: vg=VG_nfs lv=copr-be size=20t shrink=no
      tags:
        - drives
        - copr

    - name: Create FS for copr-be
      filesystem: fstype=xfs dev=/dev/VG_nfs/copr-be
      tags:
        - drives
        - copr

    - name: Create copr-be tree directory
      file: path=/srv/nfs/copr-be state=directory owner=root group=root
      tags:
        - drives
        - copr

    - name: Mount copr-be tree directory
      mount: name=/srv/nfs/copr-be src=/dev/mapper/VG_nfs-copr--be fstype=xfs state=mounted
      tags:
        - drives
        - copr

- name: Deal with NFS
  hosts: storinator01.rdu-cc.fedoraproject.org
  user: root
  gather_facts: True
  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"
  roles:
  - nfs/server
